package cn.iocoder.yudao.module.call.mq.consumer.inittenant;

import cn.iocoder.yudao.module.call.service.agent.AgentService;
import cn.iocoder.yudao.module.call.service.ivrkeywords.IvrKeywordsService;
import cn.iocoder.yudao.module.call.service.ivrknowledgeissue.IvrKnowledgeIssueService;
import cn.iocoder.yudao.module.system.mq.message.inittenant.InitTenantMessage;
import cn.iocoder.yudao.module.system.mq.message.product.ProductSendMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Objects;

/**
 * 针对 {@link InitTenantMessage} 的消费者
 *
 * @author PetePower
 */
@Component
@Slf4j
public class CallInitTenantConsumer {

    @Resource
    private IvrKnowledgeIssueService ivrKnowledgeIssueService;

    @Resource
    private IvrKeywordsService ivrKeywordsService;

    @EventListener
    @Async // Spring Event 默认在 Producer 发送的线程，通过 @Async 实现异步
    public void onMessage(InitTenantMessage message) {
        ivrKnowledgeIssueService.initDefaultKnowledge();
        ivrKeywordsService.initDefault();
    }

}
